import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import mutations from './mutations'
import { getUserInfo } from "@/api/user"

Vue.use(Vuex)

export default new Vuex.Store({
    state: state,
    actions: {
        getUserInfo({ commit }) {
            return new Promise((resolve, reject) => {
                getUserInfo({}).then(res => {
                    commit('setUserInfo', res.data)
                    console.log('Promise对象resolve：'+res)
                    resolve(res)
                }).catch(err => {
                    reject(err)
                    console.log('Promise对象reject'+err)
                })
            })
        }
    },
    mutations: mutations
})
